function migr_checker(pos){
	target_var = document.form_cldup.mgr_CL.value;
	input_var = document.form_cldup.tmp_mgrcheck[pos];
	if(input_var.disabled==false) {
		if(input_var.checked==true) {
			document.form_cldup.mgr_CL.value+=','+input_var.value;
		} else {
			document.form_cldup.mgr_CL.value=target_var.replace(','+input_var.value,"");				
		}	
	}          
}
function mnt_checker(pos) {
	$stat = 0;
	if (document.form_cldup.tmp_mntcheck[pos].checked == false) {
		$stat = false;
			document.form_cldup.sel_CL.value='';			
	} else {
		$stat = true;
			document.form_cldup.sel_CL.value=document.form_cldup.tmp_mntcheck[pos].value;
	}
	for ($i=0;$i<document.form_cldup.tmp_mntcheck.length;$i++){
		if(document.form_cldup.tmp_mntcheck[$i].value != document.form_cldup.tmp_mntcheck[pos].value) {
			document.form_cldup.tmp_mntcheck[$i].disabled = $stat;
		} else {
			if (document.form_cldup.tmp_mgrcheck[$i].checked==true) {
				document.form_cldup.tmp_mgrcheck[$i].checked=false;
				migr_checker(pos);
			}
			document.form_cldup.tmp_mgrcheck[$i].disabled=$stat;
		}
	}
}
function migr_submit() {
	if (document.form_cldup.sel_CL.value=='') {
		alert('Erro 1283: Nao existe um ficha de cliente seleccionado.');
    } else if(document.form_cldup.mgr_CL.value=='') {
		alert('Erro 1284: Nao existem clientes seleccionados para migrar.');
    } else {
		document.form_cldup.action='_response/call.php?get=Operative/remittance&CL_DB=0';
		subform('form_cldup','do_clientmigr');
    }
}
function open_view(value) {
	replaceUrl('CLPanel','_response/call.php?get=Operative/view/frm_CL&CL='+value);
	
	Ext.onReady(function(){
		Ext.getCmp('ActiveObName').setText('CLIENTE');
		Ext.getCmp('ActiveOb').setText('CL');
		Ext.getCmp('ActiveObID').setText(value);
		Ext.getCmp('qwinResults').close();
	});
}